﻿using System;
using System.Web;
using System.Web.Security;
using Hematology.HmtMembership.Interface;
using Hematology.Tools.Storage;

namespace Hematology.HmtMembership.Service
{
	public class FormsAuthenticationService : IFormsAuthenticationService
	{
		public void SignIn(string userName, bool createPersistentCookie)
		{
			if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");

			FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
		}

		public void SignOut()
		{
			FormsAuthentication.SignOut();
			SessionHelper.ActiveUser = null;
			CookieHelper.CookieUser = null;
			HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
		}
	}
}
